home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
utils
/
filestuf.lzh
/
EXAMPLE2.CMD
< prev
next >
Wrap
OS/2 REXX Batch file
|
1990-08-22
|
5KB
|
152 lines
;Example script 2...
s
s We're in the second example script now. You've seen how the ECHO command
s can turn off the echo of file commands. I'm going to turn it back on now so
s you can watch the command lines used in this demo.
s
e +
b
p 15
s In this example script, we'll demonstrate Filestuff's File Commands.
s Filestuff has the ability to copy, rename, or delete files, or to branch
s if a particular file exists. If any errors occur in the process, you can
s have Filestuff display an error message, branch to another part of the
s script, or both. You can also ignore errors if you wish.
s
b
p 18
s Filestuff uses your ST's memory as a work area to hold both the script
s you're running and any file you wish to copy. If you're interested in
s finding out just how much work space is available, use the "?" command;
s it will display the size of the work area in hexadecimal. The largest file
s you can copy will be this size minus the size of the current script. Right
s now, you have this much space available:
s
? -- display work area size
s
b
p 20
s Now for the file commands. First, you can check for the existence of a
s file and branch if it's found. Just to be sure, let's see if EXAMPLE2.CMD
s is anywhere around (it should be, this is it!)...
s
fexists \example2.cmd 10 -- jump to label 10 if it's there
s
s WHOOPS! The file isn't where it should be!
s
s Since I need the file handy to demonstrate the file commands, there's no
s point in going any further. Please copy EXAMPLE2.CMD into the root
s directory of your disk, then run this script again.
s
b
p 30
b
quit
;------------------------
@ 10
s
s Ok, found it right where it should be, in the root directory.
b
p 10
s
s Just for fun, let's check for a file you probably DON'T have...
s
f \whoopie.do! 20
s
s Nope, not there... I'm SOOO glad! <grin>
j 25
@ 20
s
s How strange, you p DO q have a file named WHOOPIE.DO!......
s (I'm going to rename it now because I need the name later...)
s
ren \whoopie.do! \hah!moo!.<g>
@ 25
b
p 10
s
s Anyway, on with the demo. First, I'm going to show you what you can do
s if there's an error with a copy, rename, or delete command. I'll try to
s make a copy of WHOOPIE.DO!, which you SHOULDN'T have around...
s
b
p 10
copy \whoopie.do! \hah.moo
s
s Now we can check for errors. To let Filestuff display its error message,
s use the "Z" command p alone on the command line q, which results in a
s display like this:
s
z
s
b
p 11
s You can use the "Z LABEL" form of the command to jump to your own error
s routine instead of (or in addition to) having Filestuff's message...
s
z 29 -- jump to label 29 if there was an error
s What, no error? You actually _had_ a WHOOPIE.DO! file?????
j 30
@ 29
s Warning! Error! No WHOOPIE.DO! file found! Oh no! Woe is me! :-)
@ 30
s
b
p 11
s
s Ok, all that's really left are the file commands - the main reason for
s having Filestuff in the first place! I'm going to start by making a few
s copies of EXAMPLE2.CMD to work with. (Note that I'm starting with the copy
s named TEST3 first, not with TEST1...)
s
copy \example2.cmd \test3
c \example2.cmd \test2
copythisfile \example2.cmd \test1
s
b
p 20
s Note that you only need to use the first character of the command; any
s characters after the first are ignored.
s
s Next, I'm going to use the Delete command. I'll use a wildcard here just
s to show you what happens - namely, the command will only affect the FIRST
s matching filename, it WON'T delete all matching files!
s
del \tes*
s
b
p 10
s Right now you should have only TEST1 and TEST2 on your disk - the other
s file, TEST3, should have been deleted. Why TEST3 and not TEST1? That's
s because I created TEST3 _before_ TEST1... even though TEST1 comes first in
s alphabetical order, TEST3 came first in your disk's directory. Remember
s this if you decide to use wildcards in your scripts...
s
b
p 20
s Ok, the last command is the RENAME command. It's pretty simple. The only
s thing to watch out for is to make sure that your file's new name isn't
s already being used in that folder - if it is, you'll get an error.
s
ren \test2 \whoopie.do!
s
s Hah! Moo! I just KNEW you wanted a file with that name! <grin!>
s
b
p 15
s One more note - you can also use the Rename command to p move q a file
s to a different folder on the same disk! One of GEMDOS's more convenient,
s if less used, features.
s
b
p 5
s
s Well, that's it for the tour! I hope you get some good use from
s Filestuff. Send me a card and let me know how it works for you!
s
s Bill Aycock
s August 22, 1990
b
p 20
b